<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui" xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:hf="http://happyfaces.org/happyfaces">

<ui:composition>

	<!-- No is is set. -->
	<c:if test="${empty id}">
		<c:set var="id" value="popupId" />
	</c:if>

	<p:dialog id="dialog" header="#{header}" widgetVar="dlg" dynamic="true">
		<!-- Set entity variable. -->
		<c:set var="entity" value="#{backingBean.instance}" />
		<h:form id="popupForm">
			<h:panelGrid id="#{id}searchFormPanel" columns="2">
				<c:if test="${not empty searchField1}">
					<hf:searchField label="#{searchField1Label}" field="#{searchField1}" />
				</c:if>
				<c:if test="${not empty searchField2}">
					<hf:searchField label="#{searchField2Label}" field="#{searchField2}" />
				</c:if>
				<c:if test="${not empty searchField3}">
					<hf:searchField label="#{searchField3Label}" field="#{searchField3}" />
				</c:if>
			</h:panelGrid>
			<h:panelGrid columns="2">
				<p:commandButton id="buttonSearch" value="#{messages['commons.search']}" update="popupForm" />
				<p:commandButton id="buttonClear" action="#{backingBean.clean}" reRender="#{formId}" value="#{messages['commons.clean']}" update="popupForm" />
			</h:panelGrid>
			<p:dataTable id="datatable" var="e" value="#{backingBean.lazyDataModel}" rows="10" selection="#{selection}" selectionMode="single"
				lazy="true">
				<p:ajax event="rowSelect" oncomplete="dlg.hide()" update="#{updateField}" />

				<c:if test="${not empty column1}">
					<p:column>
						<f:facet name="header">
							<h:outputText value="#{column1Label}" />
						</f:facet>
						<h:outputText value="#{e[column1]}" />
					</p:column>
				</c:if>
				<c:if test="${not empty column2}">
					<p:column>
						<f:facet name="header">
							<h:outputText value="#{column2Label}" />
						</f:facet>
						<h:outputText value="#{e[column2]}" />
					</p:column>
				</c:if>
				<c:if test="${not empty column3}">
					<p:column>
						<f:facet name="header">
							<h:outputText value="#{column3Label}" />
						</f:facet>
						<h:outputText value="#{e[column3]}" />
					</p:column>
				</c:if>
			</p:dataTable>
		</h:form>
	</p:dialog>

</ui:composition>

</html>